#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sem.h>
#include <sys/ipc.h>
#include <inttypes.h>
#include <time.h>
#include <cstring.h>
#include <hexstr.h>
#include <genrand.h>
#include <systime.h>
#include <logbase.h>

// common type operate struct
#define checkHexCvtSize 128
int main(int argsize, const char **args)
{
    char hexbuf[checkHexCvtSize], hexstr[checkHexCvtSize * 2], hexdec[checkHexCvtSize];
    sysTmDefBeg(tmptmr);
    int tmpcount = 0;

    genRandHexBuf(hexbuf, sizeof(hexbuf));
    cvtHex2str(hexbuf, sizeof(hexbuf), hexstr, sizeof(hexstr));
    logdebugc("%.*s", (int)sizeof(hexstr), hexstr);
    {
        char tmpHexstr[sizeof(hexbuf) * 2 + 1];
        cvtHex2str(hexbuf, sizeof(hexbuf), tmpHexstr, sizeof(tmpHexstr));
        logdebugc("%s", tmpHexstr);
    }

    cvtStr2hex(hexstr, sizeof(hexstr), hexdec, 64);
    {
        char tmpHexstr[sizeof(hexdec) * 2 + 1];
        cvtHex2str(hexdec, sizeof(hexdec), tmpHexstr, sizeof(tmpHexstr));
        logdebugc("%s", tmpHexstr);
    }

    while(sysTmRunSec(tmptmr) < 10)
    {
        genRandHexBuf(hexbuf, sizeof(hexbuf));
        cvtHex2str(hexbuf, sizeof(hexbuf), hexstr, sizeof(hexstr));
        // logdebugc("%.*s", (int)sizeof(hexstr), hexstr);
        cvtStr2hex(hexstr, sizeof(hexstr), hexdec, sizeof(hexdec));
        if(memcmp(hexbuf, hexdec, sizeof(hexdec)) != 0)
        {
            logerrorc("");
            break;
        }
        tmpcount++;
        // sleep(1);
    }
    logdebugc("%d", tmpcount);
    return 0;
}